package com.financing.platform.dao.impl;

import java.util.List;
import java.util.Map;

import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpFundBuynoticeDao;
import com.financing.platform.dto.FpFundBuynoticeDTO;
import com.financing.platform.util.SqlName;

import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpFundBuynotice")
public class FpFundBuynoticeDaoImpl extends BaseDaoImpl implements IFpFundBuynoticeDao {
	
	@Override
	public FpFundBuynoticeDTO getFpFundBuynotice(FpFundBuynoticeDTO requestDto) {
		try{
			return (FpFundBuynoticeDTO)this.sqlMapClient.queryForObject(SqlName.fpFundBuynotice,requestDto);
		} catch (SQLException e) {
			log.error("get fpFundBuynotice error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpFundBuynotice(FpFundBuynoticeDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpFundBuynotice,dto);
		} catch (SQLException e) {
			log.error("add fpFundBuynotice error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpFundBuynotice(Map map) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpFundBuynotice, map);
		} catch (SQLException e) {
			this.log.error("update fpFundBuynotice error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpFundBuynotice(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpFundBuynotice, id);
		} catch (SQLException e) {
			log.error("del fpFundBuynotice error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpFundBuynoticeDTO> listFpFundBuynotice(FpFundBuynoticeDTO dto) {
		try {
			return (List<FpFundBuynoticeDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundBuynotice, dto);
		} catch (SQLException e) {
			log.error("Query fpFundBuynotice note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpFundBuynotice(FpFundBuynoticeDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpFundBuynotice, dto);
		} catch (SQLException e) {
			log.error("Query fpFundBuynotice note list error !", e);
			return 0;
		}
	}
	
}
